<?php
class MsepCore_JsonController extends Core_Controller_Action_Standard {
	
	public function init() {
		$ajaxContext = $this->_helper->getHelper ( 'AjaxContext' );
		$ajaxContext->addActionContext ( 'categories', 'json' )->initContext ();
		
		$this->getRequest ()->setParam ( 'format', 'json' );
	}
	
	public function indexAction() {
	
	}
	
	public function categoriesAction() {
		$api = preg_replace ( '/[^a-zA-Z]/', '', $this->_getParam ( 'api' ) );
		$categories = Engine_Api::_ ()->getApi ( 'core', $api )->getAllCategoriesArray ();
		
		$this->view->error = false;
		
		if (empty ( $categories )) {
			$this->view->error = true;
		} else {
			$this->view->categories = $categories;
		}
	}

}